<template>
  <form-item :form-datas = "formDatas" :form-item = "field" :parent-comp-type = "parentCompType"
  >
    <el-input :autocomplete = "field.preps['autocomplete']"
              :autosize = "field.preps['autosize']"
              :clearable = "field.preps.clearable"
              :disabled = "field.preps.disabled"
              :input-style = "field.preps['inputStyle']"
              :max = "field.preps['max']"
              :maxlength = "field.preps.maxlength"
              :min = "field.preps['min']"
              :minlength = "field.preps.maxlength"
              :placeholder = "field.preps.placeholder"
              :prefix-icon = "field.preps['prefixIcon']"
              :readonly = "field.preps['readonly']"
              :resize = "field.preps['resize']"
              :rows = "field.preps['rows']"
              :show-password = "field.preps['showPassword']"
              :show-word-limit = "field.preps['showWordLimit']"
              :size = "field.preps.size"
              :step = "field.preps['step']"
              :suffix-icon = "field.preps['suffixIcon']"
              :tabindex = "field.preps['tabindex']"
              :type = "field.preps.type"
              @blur = "dynamicFunction(field.preps['blur'])"
              @change = "dynamicFunction(field.preps['change'])"
              @focus = "dynamicFunction(field.preps['focus'])"
              v-model = "starHorseDynamicForm[field.preps['name']]"/>
  </form-item>
</template>

<script>
import FormItem from "./form-item";

export default {
  name: "input-item",
  components: {FormItem},
  props: {
    parentCompType: {type: Object},
    starHorseDynamicForm: {type: Object},
    field: {
      type: Object
    },
    formDatas: {type: Object}
  },
  data() {
    let formItem = {label: "input", required: false};
    return {
      formItem,
      dataField: ""
    }
  },
  methods: {
    dynamicFunction(data) {
      if (!data) {
        return;
      }
      let fun = new Function(data);
      fun();
    },
    selectItem(data) {
      let _this = this;
      alert(33);
      _this.$emit("selectItem", data, _this.parentCompType);
    }
  }
}
</script>

<style scoped>

</style>